package com.flash.variety.service.impl;

import java.util.List;

import com.flash.variety.domain.CuisinePreferential;
import com.flash.variety.mapper.CuisinePreferentialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.flash.variety.mapper.TbCuisineMapper;
import com.flash.variety.domain.TbCuisine;
import com.flash.variety.service.ITbCuisineService;

/**
 * 菜品Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-01-06
 */
@Service
public class TbCuisineServiceImpl implements ITbCuisineService 
{
    @Autowired
    private TbCuisineMapper tbCuisineMapper;

    @Autowired
    private CuisinePreferentialMapper cuisinePreferentialMapper;

    /**
     * 查询菜品
     * 
     * @param cuisineId 菜品主键
     * @return 菜品
     */
    @Override
    public TbCuisine selectTbCuisineByCuisineId(Long cuisineId)
    {
        return tbCuisineMapper.selectTbCuisineByCuisineId(cuisineId);
    }

    /**
     * 查询菜品列表
     * 
     * @param tbCuisine 菜品
     * @return 菜品
     */
    @Override
    public List<TbCuisine> selectTbCuisineList(TbCuisine tbCuisine)
    {
        return tbCuisineMapper.selectTbCuisineList(tbCuisine);
    }

    /**
     * 新增菜品
     * 
     * @param tbCuisine 菜品
     * @return 结果
     */
    @Override
    public int insertTbCuisine(TbCuisine tbCuisine)
    {
        int i = tbCuisineMapper.insertTbCuisine(tbCuisine);
        CuisinePreferential cuisinePreferential = new CuisinePreferential();
        cuisinePreferential.setCuisineId(tbCuisine.getCuisineId());
        cuisinePreferential.setPreferentialId(tbCuisine.getPreferentialId());
        cuisinePreferentialMapper.saveCuisine(cuisinePreferential);
        return i;
    }

    /**
     * 修改菜品
     * 
     * @param tbCuisine 菜品
     * @return 结果
     */
    @Override
    public int updateTbCuisine(TbCuisine tbCuisine)
    {
        CuisinePreferential cuisinePreferential = new CuisinePreferential();
        cuisinePreferential.setCuisineId(tbCuisine.getCuisineId());
        cuisinePreferential.setPreferentialId(tbCuisine.getPreferentialId());
        cuisinePreferentialMapper.updateCuisine(cuisinePreferential);
        return tbCuisineMapper.updateTbCuisine(tbCuisine);
    }

    /**
     * 批量删除菜品
     * 
     * @param cuisineIds 需要删除的菜品主键
     * @return 结果
     */
    @Override
    public int deleteTbCuisineByCuisineIds(Long[] cuisineIds)
    {
        return tbCuisineMapper.deleteTbCuisineByCuisineIds(cuisineIds);
    }

    /**
     * 删除菜品信息
     * 
     * @param cuisineId 菜品主键
     * @return 结果
     */
    @Override
    public int deleteTbCuisineByCuisineId(Long cuisineId)
    {
        return tbCuisineMapper.deleteTbCuisineByCuisineId(cuisineId);
    }

  /*  @Override
    public int saveCuisine(CuisinePreferential cuisinePreferential) {
        return 0;
    }*/
}
